'''
  @Description      
  @auther         leizi
  @create          2020-02-09 15:00
'''
from until.log import LOG, logger


@logger("读取文件")
def read_file(filename):
    all_result = None
    log_reslut = []
    with open(filename, 'r', encoding='utf-8') as f:
        name = f.readlines()
        for i in range(len(name)):
            if "Events injected" in name[i]:
                all_result = (name[i:len(name)])
            elif "java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission" in \
                    name[i]:
                relut = ''
                for n in name[i - 1:]:
                    if "[Maxim]" not in n:
                        relut += n
                log_reslut.append(relut)
    caozuo_num = all_result[0].split(":")[1].capitalize()
    run_activity = []
    for item in all_result:
        if "Activity" in item and "Activity of Coverage" not in item:
            run_activity.append(item.split("-")[1].capitalize().split("\n")[0])
    return caozuo_num, run_activity, log_reslut
